<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />
<div class="t_bar">
    <span class="color_red">*</span>立项情况
</div>
<table>
    <col style="width: 13%" />
    <col style="width: 13%" />
    <col style="width: 74%" />
    <tr>
        <td align="right" rowspan="3">
            课题来源：<br />（单选）
        </td>
        <td align="right">国家科技计划：</td>
        <td>
            <c:set var="results_registration_form7_value">
                <x:out select="$xmlData/data/proposal/results_registration_form7_value" />
            </c:set>
            <c:set var="results_registration_form7_other">
                <x:out select="$xmlData/data/proposal/results_registration_form7_other" />
            </c:set>
            <cpt:checkbox key="results_registration_form7" name="results_registration_form7"
                repeatColumn="2" value="${results_registration_form7_value }" lastOther="true"
                otherId="results_registration_form7_other" onClick="setTopicSuorce('01');"
                otherValueName="${results_registration_form7_other }" tagType="radio"></cpt:checkbox>
            <input type="text" id="results_registration_form7_other"
                name="proposal/results_registration_form7_other" mxlength="50"
                style="border: none; border-bottom: 1px solid gray; width: 100px;"
                label="课题来源-->国家科技计划 -->其他国家科技计划"
                value="<x:out select="$xmlData/data/proposal/results_registration_form7_other"/>" />
            <input type="hidden" id="results_registration_form7_value"
                name="proposal/results_registration_form7_value" class=""
                value="${results_registration_form7_value}" label="课题来源">
            <input type="hidden" name="proposal/results_registration_form7_name"
                value="<x:out select="$xmlData/data/proposal/results_registration_form7_name" />">
        </td>
    </tr>
    <tr>
        <td align="right">省科技厅计划 ：</td>
        <td colspan="2">
            <c:set var="results_registration_form8_value">
                <x:out select="$xmlData/data/proposal/results_registration_form8_value" />
            </c:set>
            <cpt:checkbox key="results_registration_form8" name="results_registration_form8"
                repeatColumn="2" value="${results_registration_form8_value }"
                onClick="setTopicSuorce('02');" tagType="radio"></cpt:checkbox>
            <input type="hidden" id="results_registration_form8_value"
                name="proposal/results_registration_form8_value" class="required"
                value="${results_registration_form8_value}" label="课题来源 ">
            <input type="hidden" name="proposal/results_registration_form8_name"
                value="<x:out select="$xmlData/data/proposal/results_registration_form8_name" />">
        </td>
    </tr>

    <tr>
        <td colspan="2">
            <c:set var="results_registration_form9_value">
                <x:out select="$xmlData/data/proposal/results_registration_form9_value" />
            </c:set>
            <cpt:checkbox key="results_registration_form9" name="results_registration_form9"
                repeatColumn="4" value="${results_registration_form9_value }"
                onClick="setTopicSuorce();" tagType="radio"></cpt:checkbox>
            <input type="hidden" id="results_registration_form9_value"
                name="proposal/results_registration_form9_value" class="required"
                value="${results_registration_form9_value}" label="课题来源 ">
            <input type="hidden" name="proposal/results_registration_form9_name"
                value="<x:out select="$xmlData/data/proposal/results_registration_form9_name" />">
        </td>
    </tr>
    <tr>
        <td align="right">课题来源单位：</td>
        <td colspan="2">
            <input name="proposal/topic_suorce_unit" style="width: 622px;" label="课题来源单位"
                class="required" maxlength="50"
                value="<x:out select="$xmlData/data/proposal/topic_suorce_unit"/>" />
        </td>
    </tr>
    <tr>
        <td align="right">课题立项名称：</td>
        <td colspan="2">
            <input name="proposal/topic_prj_unit" style="width: 622px;" label="课题立项名称"
                class="required" maxlength="50"
                value="<x:out select="$xmlData/data/proposal/topic_prj_unit"/>" />
        </td>
    </tr>
    <tr>
        <td align="right">课题立项编号：</td>
        <td colspan="2">
            <input name="proposal/topic_prj_code" style="width: 622px;" label="课题立项编号"
                class="required" maxlength="50"
                value="<x:out select="$xmlData/data/proposal/topic_prj_code"/>" />
        </td>
    </tr>
</table>
<table style="text-align: center;" id="fund_tab">
    <col style="width: 10%" />
    <col style="width: 8%" />
    <col style="width: 8%" />
    <col style="width: 10%" />
    <col style="width: 8%" />
    <col style="width: 8%" />
    <col style="width: 8%" />
    <col style="width: 8%" />
    <col style="width: 8%" />
    <col style="width: 8%" />
    <col style="width: 8%" />
    <col style="width: 8%" />
    <tr>
        <td colspan="12" align="left">经费实际投入额（万元）</td>
    </tr>
    <tr>
        <td rowspan="2">总计</td>
        <td rowspan="2">国家投入</td>
        <td rowspan="2">部门投入</td>
        <td colspan="4">地方投入</td>
        <td rowspan="2">基金投入</td>
        <td rowspan="2">自有资金</td>
        <td rowspan="2">银行贷款</td>
        <td rowspan="2">国外资金</td>
        <td rowspan="2">其他</td>
    </tr>
    <tr>
        <td>合计</td>
        <td>省级投入</td>
        <td>地级投入</td>
        <td>县级投入</td>
    </tr>
    <tr>
        <td>
            <input name="proposal/actual_input_fund1" id="actual_input_fund1"
                value="<x:out select="$xmlData/data/proposal/actual_input_fund1"/>" class="gray"
                style="width: 80%; text-align: right;" />
        </td>
        <td>
            <input name="proposal/actual_input_fund2" id="actual_input_fund2" label="经费实际投入额-->国家投入"
                onfocus="InitInput.setNumber(this,9,2,2);"
                value="<x:out select="$xmlData/data/proposal/actual_input_fund2"/>" class="required"
                style="width: 80%; text-align: right;" />
        </td>
        <td>
            <input name="proposal/actual_input_fund3" id="actual_input_fund3" label="经费实际投入额-->部门投入"
                onfocus="InitInput.setNumber(this,9,2,2);"
                value="<x:out select="$xmlData/data/proposal/actual_input_fund3"/>" class="required"
                style="width: 80%; text-align: right;" />
        </td>
        <td>
            <input name="proposal/actual_input_fund4" id="actual_input_fund4"
                value="<x:out select="$xmlData/data/proposal/actual_input_fund4"/>" class="gray"
                style="width: 80%; text-align: right;" />
        </td>
        <td>
            <input name="proposal/actual_input_fund5" id="actual_input_fund5"
                label="经费实际投入额-->地方投入-->省级投入" onfocus="InitInput.setNumber(this,9,2,2);"
                value="<x:out select="$xmlData/data/proposal/actual_input_fund5"/>" class="required"
                style="width: 80%; text-align: right;" />
        </td>
        <td>
            <input name="proposal/actual_input_fund6" id="actual_input_fund6"
                label="经费实际投入额-->地方投入-->地级投入" onfocus="InitInput.setNumber(this,9,2,2);"
                value="<x:out select="$xmlData/data/proposal/actual_input_fund6"/>" class="required"
                style="width: 80%; text-align: right;" />
        </td>
        <td>
            <input name="proposal/actual_input_fund7" id="actual_input_fund7"
                label="经费实际投入额-->地方投入-->县级投入" onfocus="InitInput.setNumber(this,9,2,2);"
                value="<x:out select="$xmlData/data/proposal/actual_input_fund7"/>" class="required"
                style="width: 80%; text-align: right;" />
        </td>
        <td>
            <input name="proposal/actual_input_fund8" id="actual_input_fund8" label="经费实际投入额-->基金投入"
                onfocus="InitInput.setNumber(this,9,2,2);"
                value="<x:out select="$xmlData/data/proposal/actual_input_fund8"/>" class="required"
                style="width: 80%; text-align: right;" />
        </td>
        <td>
            <input name="proposal/actual_input_fund9" id="actual_input_fund9" label="经费实际投入额-->自有资金"
                onfocus="InitInput.setNumber(this,9,2,2);"
                value="<x:out select="$xmlData/data/proposal/actual_input_fund9"/>" class="required"
                style="width: 80%; text-align: right;" />
        </td>
        <td>
            <input name="proposal/actual_input_fund10" id="actual_input_fund10"
                label="经费实际投入额-->银行贷款" onfocus="InitInput.setNumber(this,9,2,2);"
                value="<x:out select="$xmlData/data/proposal/actual_input_fund10"/>"
                class="required" style="width: 80%; text-align: right;" />
        </td>
        <td>
            <input name="proposal/actual_input_fund11" id="actual_input_fund11"
                label="经费实际投入额-->国外资金" onfocus="InitInput.setNumber(this,9,2,2);"
                value="<x:out select="$xmlData/data/proposal/actual_input_fund11"/>"
                class="required" style="width: 80%; text-align: right;" />
        </td>
        <td>
            <input name="proposal/actual_input_fund12" id="actual_input_fund12" label="经费实际投入额-->其他"
                onfocus="InitInput.setNumber(this,9,2,2);"
                value="<x:out select="$xmlData/data/proposal/actual_input_fund12"/>"
                class="required" style="width: 80%; text-align: right;" />
        </td>
    </tr>
</table>
<script>
$("#actual_input_fund5,#actual_input_fund6,#actual_input_fund7").change(function(){
    getTotalCount('actual_input_fund', '5,6,7', '4', true);
});
$("#fund_tab :input").change(function(){
	getTotalCount('actual_input_fund', '2,3,4,8,9,10,11,12', '1', true);
});
	function setTopicSuorce(code) {
		var finance_support_dept_value = $("#finance_support_dept_value");
		var results_registration_form7 = $("input:radio[name='results_registration_form7']");
		var results_registration_form8 = $("input:radio[name='results_registration_form8']");
		var results_registration_form9 = $("input:radio[name='results_registration_form9']");
		var results_registration_form7_value = $("#results_registration_form7_value");
		var results_registration_form8_value = $("#results_registration_form8_value");
		var results_registration_form9_value = $("#results_registration_form9_value");
		
		if (code == "01") {
			finance_support_dept_value.val(code);
			results_registration_form8.removeAttr("checked");
			results_registration_form9.removeAttr("checked");
			results_registration_form8_value.val("");
			results_registration_form9_value.val("");
		} else if (code == "02") {
			finance_support_dept_value.val(code);
			results_registration_form7.removeAttr("checked");
			results_registration_form9.removeAttr("checked");
			results_registration_form7_value.val("");
			results_registration_form9_value.val("");
		} else {
			var results_registration_form9_value = $("#results_registration_form9_value").val();
			finance_support_dept_value.val(results_registration_form9_value);
			results_registration_form7.removeAttr("checked");
			results_registration_form8.removeAttr("checked");
			results_registration_form7_value.val("");
			results_registration_form8_value.val("");
		}
	}
	/**
	----------------------by zk
	        参数prefix：公共的id开头
	        参数count：需要加的数的id结尾     以,分割
	        参数total：总数id结尾
	        参数isDeciaml：是否为小数 默认为false
	 */
	function getTotalCount(prefix, count, total, isDecimal) {
		var defaultIsDecimal = false;//默认为整数
		if (isDecimal == null) {
			isDecimal = defaultIsDecimal;
		}
		var numStr = count.split(',');
		var totalCount = 0;//总数
		if (!isDecimal) {
			for ( var int = 0; int < numStr.length; int++) {
				var num = $('#' + prefix + numStr[int]).val();
				if (!$.isNumeric(num))
					num = "0";
				totalCount += parseInt(num);
			}
		} else {
			for ( var int = 0; int < numStr.length; int++) {
				var num = $('#' + prefix + numStr[int]).val();
				if (!$.isNumeric(num))
					num = "0";
				totalCount += parseFloat(num);
			}
			totalCount = ((totalCount / 100) * 100).toFixed(2);
		}
		
		$('#' + prefix + total).val(totalCount);
		
	}
</script>